-
Notifications
You must be signed in to change notification settings - Fork 21
add grpc backed EventSubscriber and example #165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
crates/src/event_subscriber.rs
Outdated
|
||
let raw_event_tx_clone = raw_event_tx.clone(); | ||
grpc.on_transaction(Box::new(move |tx_update: TransactionUpdate| { | ||
raw_event_tx_clone.try_send(tx_update).unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to handle the update inline here? maybe then can pass TransactionUpdate by ref
raw_event_tx_clone.try_send(tx_update).unwrap(); | |
let start = std::time::Instant::now(); | |
let slot = event.slot; | |
self.process_log(event).await; | |
let elapsed = start.elapsed(); | |
debug!(target: "grpc", "transaction slot: {}, len: {} callbacks took {:?}", slot, raw_event_rx.len(), elapsed); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couldn't get this to work since process_log
is async. Maybe i should change grpc.on_transaction
to take async callbacks?
let tx = match tx_update.transaction { | ||
Some(ref tx) => tx, | ||
None => { | ||
warn!(target: "grpc", "empty transaction update: {tx_update:?}"); | ||
continue; | ||
} | ||
}; | ||
let transaction = match tx.transaction { | ||
Some(ref tx) => tx, | ||
None => { | ||
warn!(target: "grpc", "empty transaction update: {tx_update:?}"); | ||
continue; | ||
} | ||
}; | ||
let meta = match tx.meta { | ||
Some(ref meta) => meta, | ||
None => { | ||
warn!(target: "grpc", "empty transaction meta: {tx_update:?}"); | ||
continue; | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wondering what happens if valid tx but has no meta? not sure if that'll happen in practice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i dont think it'll happen in practice, but i feel it's safer to check. I saw a surprising number of tx logs without signatures (11111...) from websocket, but none were like that from grpc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, we can always optimize the little things if we need to later
EventSubscriber::subscribe_grpc
to start anEventSubscriber
backed by yellowstone grpccloses #154